var t = getApp();

Page({
    data: {
        recordsList: [],
        activity_name: "",
        lotteryId: "",
        isLoadMore: !0,
        page: 1,
        total_page: 0
    },
    onLoad: function(t) {
        t.lotteryId && this.setData({
            lotteryId: t.lotteryId
        }), this.initData(), this.getData();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {},
    initData: function() {
        this.setData({
            activity_name: "",
            recordsList: [],
            page: 1,
            total_page: 0,
            isLoadMore: !0
        });
    },
    getData: function() {
        var a = this, o = {
            lotteryId: this.data.lotteryId
        }, e = t.getNetAddresss("plugin.lucky-draw.frontend.draw.getMyRecord");
        t._getNetWork({
            url: e,
            data: o,
            success: function(t) {
                var o = t.data;
                1 == o.result ? (a.setData({
                    amount_word: o.data.amount_word,
                    love_word: o.data.love_word,
                    point_word: o.data.point_word,
                    isLoadMore: !0,
                    page: 1,
                    activity_name: o.data.activity_name,
                    total_page: o.data.my_record.last_page
                }), a.data.total_page || a.setData({
                    total_page: 0
                }), a.setData({
                    recordsList: o.data.my_record.data
                })) : wx.showToast({
                    title: o.msg,
                    icon: "none",
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMoreData: function() {
        var a = this, o = {
            page: a.data.page,
            lotteryId: this.data.lotteryId
        }, e = t.getNetAddresss("plugin.lucky-draw.frontend.draw.getMyRecord");
        a.setData({
            isLoadMore: !1
        }), this.data.page >= this.data.total_page || (this.data.page = this.data.page + 1, 
        t._getNetWork({
            url: e,
            data: o,
            success: function(t) {
                var o = t.data;
                if (a.setData({
                    isLoadMore: !0
                }), 1 == o.result) {
                    var e = o.data.my_record.data;
                    a.setData({
                        recordsList: a.data.recordsList.concat(e)
                    });
                } else a.setData({
                    page: a.data.page - 1,
                    isLoadMore: !1
                });
            },
            fail: function(t) {
                console.log(t);
            }
        }));
    }
});